package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.CcsTcs;
import com.ruoyi.system.service.ICcsTcsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 教学班管理表Controller
 * 
 * @author ruoyi
 * @date 2024-04-21
 */
@RestController
@RequestMapping("/system/tcs")
public class CcsTcsController extends BaseController
{
    @Autowired
    private ICcsTcsService ccsTcsService;

    /**
     * 查询教学班管理表列表
     */
    @PreAuthorize("@ss.hasPermi('system:tcs:list')")
    @GetMapping("/list")
    public TableDataInfo list(CcsTcs ccsTcs)
    {
        startPage();
        List<CcsTcs> list = ccsTcsService.selectCcsTcsList(ccsTcs);
        return getDataTable(list);
    }

    /**
     * 导出教学班管理表列表
     */
    @PreAuthorize("@ss.hasPermi('system:tcs:export')")
    @Log(title = "教学班管理表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CcsTcs ccsTcs)
    {
        List<CcsTcs> list = ccsTcsService.selectCcsTcsList(ccsTcs);
        ExcelUtil<CcsTcs> util = new ExcelUtil<CcsTcs>(CcsTcs.class);
        util.exportExcel(response, list, "教学班管理表数据");
    }

    /**
     * 获取教学班管理表详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:tcs:query')")
    @GetMapping(value = "/{teacherNum}")
    public AjaxResult getInfo(@PathVariable("teacherNum") Long teacherNum)
    {
        return success(ccsTcsService.selectCcsTcsByTeacherNum(teacherNum));
    }

    /**
     * 新增教学班管理表
     */
    @PreAuthorize("@ss.hasPermi('system:tcs:add')")
    @Log(title = "教学班管理表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CcsTcs ccsTcs)
    {
        return toAjax(ccsTcsService.insertCcsTcs(ccsTcs));
    }

    /**
     * 修改教学班管理表
     */
    @PreAuthorize("@ss.hasPermi('system:tcs:edit')")
    @Log(title = "教学班管理表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CcsTcs ccsTcs)
    {
        return toAjax(ccsTcsService.updateCcsTcs(ccsTcs));
    }

    /**
     * 删除教学班管理表
     */
    @PreAuthorize("@ss.hasPermi('system:tcs:remove')")
    @Log(title = "教学班管理表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{teacherNums}")
    public AjaxResult remove(@PathVariable Long[] teacherNums)
    {
        return toAjax(ccsTcsService.deleteCcsTcsByTeacherNums(teacherNums));
    }
}
